<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 类名必须大写 */
        class Student {
            /* 构造函数:构造一个对象  */
            constructor(name, age) {
                this.name = name;
                this.age = age;
                console.log("构建对象")
                console.log(this)
                /* 构建函数中的this指new出来的对象 */
            }
        }
        /* new一个实例对象,一定会执行构造函数 */
        var li = new Student("李四", 18)
        console.log(li)
    </script>
</body>

</html>